import React, { useImperativeHandle, useState } from 'react';
import ProDialog from '@/pages/components/ProjectPopup';

const TipsPopup = React.forwardRef((props: any, ref: any) => {
    const { determineBtn } = props;
    const [twoVisible, setTwoVisible] = useState<boolean>(false);
    const [popupContent, setPopupContent] = useState<any>([]);

    useImperativeHandle(ref, () => ({
        show: async (data: any) => {
            setTwoVisible(true);
            setPopupContent(data);
        }
    }));

    return (
        <ProDialog
            ref={ref}
            visible={twoVisible}
            title='重复提示'
            width={300}
            {...props}
            onHiding={() => setTwoVisible(false)}
            onOK={async () => {
                setTwoVisible(false);
                determineBtn();
            }}
            onCancel={() => {
                setTwoVisible(false);
            }}
            contentRender={() =>
                <>
                    <div>项目
                        {popupContent.map((item: any, i: any) => (
                            <span key={i} >【{item}】</span>))}
                        重复，此操作将覆盖原有项目，是否继续？
                    </div>
                </>
            }
        />
    );
})

export default TipsPopup;
